package com.li.hello.controller;

import com.alibaba.fastjson.JSONObject;
import com.li.hello.entity.Persion;
import com.li.hello.service.PersionService;
import com.li.hello.service.impl.PersionServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersionController {

    @Autowired
    private PersionService persionService;

    @RequestMapping("/set")
    public JSONObject setData() {
        Persion persion = new Persion();
        persion.setId("1");
        persion.setAge(28);
        persion.setName("张三");
        persionService.setPersion(persion);
        JSONObject json = new JSONObject();
        json.put("success", true);
        json.put("msg", "添加成功");
        return json;
    }

    @RequestMapping("/getPersion")
    public Persion getPersion() {
        Persion persion = new Persion();
        persion.setId("1");
        persion = persionService.getPersion(persion);
        return persion;
    }
}
